<script type="text/javascript">
var gS={
	guidance:null,
	time:function (dp){
		var year = dp.cal.date.y;
		var month = dp.cal.date.M;
		if(this.guidance.length){
			this.guidance = $.map(this.guidance, function(g){
				return g.year == year && g.month == month ? g : null;
			});
		}else{
			this.base({"year":year,"month":month});
		}
		if(!this.guidance.length)return false;
		var area = new Array();
		$.each(this.guidance, function(index,g) {
			area.push(g.areaCode);
		});
		zcity.filter(area.toLocaleString());
		this.resetter();
	},
	areaCode:function (e){
		this.base({"year":"2017","month":"4"});
	},
	major:function(e){
		console.dir(e);
	},
	base:function (options){
		var options = options||{};
		$.ajaxSettings.async = false;
		$.post("/guidance_service/front/guidance/search.do",options,function(data){
			$.ajaxSettings.async = true;
			gS.guidance =data.data;
		});
	},
	resetter:function(options){
		console.dir(this.guidance.length);
		if(!this.guidance.length)return false;
		$("#major")[0].options.length=0;
		$("#guidance")[0].options.length=0;
		$.each(this.guidance, function(index,data){
			$("#major").append("<option value='"+data.major+"'>"+data.major+"</option>");
			$("#guidance").append("<option value='"+data.guidanceId+"'>"+data.guidanceName+"</option>");
		});
	}
};
var zcity = $("#area").zosoftCity({"fn":gS.areaCode()});

function guidance_open(title,url,w,h){  /*zosoft-添加*/
	var index = layer.open({
		type: 2,
		title: title,
		content: url
	});
	layer.full(index);
}

function guidance_edit(title,url,id,w,h){  /*zosoft-编辑*/
	var index = layer.open({
		type: 2,
		title: title,
		content: url
	});
	layer.full(index);
}

function guidance_del(obj,id){     /*zosoft-删除*/
	layer.confirm('确认要删除吗？',function(index){
		$.ajax({
			type: 'POST',
			url: '',
			dataType: 'json',
			success: function(data){
				$(obj).parents("tr").remove();
				layer.msg('已删除!',{icon:1,time:1000});
			},
			error:function(data) {
				console.log(data.msg);
			},
		});		
	});
}
</script> 